<%--
  Created by IntelliJ IDEA.
  User: 吕天
  Date: 2022/11/29
  Time: 16:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<html>
<head>
    <title>更新员工</title>
    <link rel="stylesheet" href="./layui/css/layui.css">
    <base href="${pageContext.request.scheme }://${pageContext.request.serverName }:${pageContext.request.serverPort }${pageContext.request.contextPath }/ "/>
</head>
<body>

<form class="layui-form" action="Emp.do?m=update" method="post" >
        <input type="hidden" name="id" value="${e.id}">
    <div class="layui-form-item">

        <label class="layui-form-label">员工姓名</label>
        <div class="layui-input-inline">
            <input type="text" name="name"  required lay-verify="required" value="${e.name}" autocomplete="off" class="layui-input"><span id="username_msg"></span>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">员工年龄</label>
        <div class="layui-input-inline">
            <input type="text" name="age"  required lay-verify="required" value="${e.age}" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">员工姓性别</label>
        <div class="layui-input-inline">
            <input type="text" name="gender"  required lay-verify="required" value="${e.gender}" autocomplete="off" class="layui-input">
        </div>
    </div>


    <%--提交--%>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">更新</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

<script src="./layui/layui.js"></script>
<script>

    $(function () {
        //给账号文本框加失去焦点事件
        $("[name=name]:text").blur(function () {
            //连接服务器校验用户名
            $.get("Emp.do?m=check&name="+$(this).val(),
                function (data) {
                    if(data == 1){
                        $("#username_msg").text("此姓名已经存在").css("color","red");
                    }else{
                        $("#username_msg").text("此名可以使用").css("color","green");
                    }
                });
        });
    })
</script>

</body>
</html>
